<?php
$_SESSION['steps'][$_GET['action']] = false;
if($_SESSION['install_id']=='')
{
	displayError('Vous devez autoriser les variables de sessions');
}
$uid = 'dev';//uniqid();
$pack_path = $temp_path.'pack_'.$uid.'.ttPackage';
$current_version = '0.0.0.0';
if(file_exists($current_path.'/install_report.php5'))
{
	include($current_path.'/install_report.php5');
	
	if($install_report['application_name']!=INSTALL_APPLICATION_NAME)
	{
		displayError('Une autre application a déjà été installé dans ce répértoire.');
	}
	$current_version = $install_report['application_version'];
}
if(compareVersions($current_version, '0.0.0.0')>0)
{
	displayError('Votre version est à jour.');
}
$xml = file_get_contents(INSTALL_PACKAGE_HOST.'index.php?action=info_version&application='.INSTALL_APPLICATION_NAME);
if($xml=='')
{
	displayError('Impossible de charger l\'index du server de packages');
}
$data = @new SimpleXMLElement($xml);
if($data->application[0]->name[0]!=INSTALL_APPLICATION_NAME)
{
	displayError('Le server de package n\'heberge pas cette application.');
}
if(is_file($pack_path))
{
	unlink($pack_path);
}

$_SESSION['pack_path'] = $pack_path;
$_SESSION['pack_downloaded'] = 0;
$_SESSION['pack_version'] = ''.$data->application[0]->version[0];
$_SESSION['pack_size'] = intval($data->application[0]->size[0]);
$_SESSION['pack_md5'] = ''.$data->application[0]->md5[0];
?>
document.getElementById('li_pack').className='install_done'
document.getElementById('install_menu_page').innerHTML=document.getElementById('li_down').innerHTML
document.getElementById('li_down').className='install_doing'

document.getElementById('install_content_intro').innerHTML = 'Votre server est en train de télécharger le packaghe pour pouvoir l\'installer par la suite...';
document.getElementById('install_content_data').innerHTML = '<div style="position:absolute;top:5px;left:10px;right:10px;border:1px solid #606060"><div style="background-color:#6999DA;width:1px;height:16px;overflow:hidden" id="div_down">&nbsp;</div><div style="position:absolute;left:0px;top:0px;right:0px;bottom:0px;text-align:center; font-weight:bold;" id="div_down_label">&nbsp;</div></div>'

ajax.sendAsync(page+'?action=down_pack&uid='+new Date().getTime(), function(datas)
{
	evalAjax(datas)
})
ajax.sendAsync(page+'?action=down_pack_info&uid='+new Date().getTime(), function(datas)
{
	evalAjax(datas)
})
